<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>综合服务系统--试题库修改</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <link rel="stylesheet" href="/plugin/it/common/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/zTree/js/jquery.ztree.all.js" charset="utf-8"></script>
</head>
<style>
    .Right {
        width: 100%;
        overflow-y: auto;
    }

    .screening ul li:nth-child(1) select, .screening ul li:nth-child(3) select, .screening ul li:nth-child(6) select {
        width: 30%;
    }

    .layui-breadcrumb a:hover {
        color: #5775EF !important;
    }

    .layui-form-radio > i:hover, .layui-form-radioed > i {
        color: #5775EF;
    }

    .layui-form-radio {
        margin: 0;
        padding: 0;
    }

    .layui-form-checked i, .layui-form-checked:hover i {
        color: #5775EF;
    }

    .layui-form-checkbox i {
        border: 1px solid #d2d2d2;
    }

    .screening button {
        width: 100px;
    }

    .layui-btn-normal {
        background: #5775EF;
    }
</style>

<body>
<!--头部-->
<div style="background-color: #F1F4FB;padding-left: 20px;">
    <span class="layui-breadcrumb" lay-separator=">">
        <a><cite>考试管理</cite></a>
        <a href="/ex/question/stkIndex"><cite>试题库</cite></a>
        <a href="#"><cite>修改试题</cite></a>
    </span>
</div>
<!--容器-->
<div class="container clearfix">
    <!--右侧内容-->
    <#--	<div class="Right fr mt10">-->
    <#--        <div class="layui-container ztree">-->
    <#--            <ul id="treeDemo"></ul>-->
    <#--        </div>-->
    <#--	</div>-->
    <div class="Right fr">
        <form class="layui-form" enctype="multipart/form-data">
            <div class="screening screeningOne whitebg clearfix" style="margin-top: 0;">
                <input type="hidden" name="quId" id="quId" value="${eq.quId}">
                <input type="hidden" name="status" id="status" value="${eq.status}">
                <div class="bold">试题设置</div>
                <ul class="clearfix fl" style="width: 100%;">
                    <li style="width: 30%;" hidden>
                        <label class="fl"><span class="red">*</span>试题分类：</label>
                        <select name="quCategory" class="ml8 " id="quCategory" lay-verify="required"
                                lay-ignore>
                            <option value="">请选择</option>
                            <#list stfl as vo>
                                <option value="${vo.badtCode}"
                                        <#if (eq.quCategory)??>
                                            <#if (eq.quCategory) ==(vo.badtCode)>
                                                selected=selected
                                            </#if>
                                        </#if>
                                >${vo.badtName}
                                </option>
                            </#list>
                        </select>
                    </li>

                    <li style="width: 30%;">
                        <div class="layui-form-item">
                            <label class="fl"><span class="red">*</span>试题分类：</label>
                            <div class="layui-input-inline">
                                <div class="layui-unselect layui-form-select downpanel">
                                    <div class="layui-select-title" >
                                        <span class="layui-input layui-unselect" style="padding-top: 8px" id="treeclass">请选择分类</span>
                                        <i class="layui-edge"></i>
                                    </div>

                                    <dl class="layui-anim layui-anim-upbit">
                                        <dd>
                                            <ul id="classtree"></ul>
                                        </dd>
                                    </dl>
                                </div>
                            </div>
                        </div>
                    </li>

                    <li style="width: 30%">
                        <label class="fl"><span class="red">*</span> 试题类型：</label>
                        <select name="quType" class="ml8 " disabled="disabled" id="quType" lay-verify="required"
                                lay-ignore>
                            <#list sttx as vo>
                                <option value="${vo.badtCode}"
                                        <#if (eq.quType)??>
                                            <#if (eq.quType) ==(vo.badtCode)>
                                                selected=selected
                                            </#if>
                                        </#if>
                                >${vo.badtName}
                                </option>
                            </#list>
                        </select>
                    </li>
                    <li style="width: 30%;">
                        <label class="fl"><span class="red">*</span> 试题难度：</label>
                        <select name="level" class="ml8 " id="level" lay-verify="required"
                                lay-ignore>
                            <option value="">请选择</option>
                            <#list stnd as vo>
                                <option value="${vo.badtCode}"
                                        <#if (eq.level)??>
                                            <#if (eq.level) ==(vo.badtCode)>
                                                selected=selected
                                            </#if>
                                        </#if>
                                >${vo.badtName}
                                </option>
                            </#list>
                        </select>
                    </li>
                </ul>
                <div class="bold"><span class="red">*</span>题目名称</div>
                <ul class="clearfix fl" style="width: 100%;">
                    <textarea id="content" lay-verify="content" name="content"
                              style="display: none;">${eq.content}</textarea>
                </ul>
                <#--            选择题-->
                <div id="dx">
                    <div class="bold"><span class="red">*</span>选项(从选项中选择一个作为答案)</div>
                    <div id="dxs">
                        <#list exq as vo>
                            <#if "${vo.isRight}"=="1">
                                <ul class="clearfix fl dx" style="width: 100%;">
                                    <input type="radio"
                                                                                               name="exDxList[0].isItRight"
                                                                                               style="display: none;"
                                                                                               checked="checked"
                                                                                               class="fl h30 w25 doBestInput"
                                                                                               value="${vo.answerContent}"><span>${vo.answerContent}</span>、<span>答案</span>
                                    <textarea id="dx${vo.serial}" lay-verify="content" class="dodx"
                                              name="exDxList[${vo.serial}].answerAnalysis">${vo.answerAnalysis}</textarea><input
                                            type="hidden" class='dxyc' name="exDxList[${vo.serial}].answerContent"
                                            value="${vo.answerContent}">
                                </ul>
                            <#else >
                                <ul class="clearfix fl dx" style="width: 100%;">
                                    <input type="radio"
                                                                                               name="exDxList[0].isItRight"
                                                                                               style="display: none;"
                                                                                               class="fl h30 w25 doBestInput"
                                                                                               value="${vo.answerContent}"><span>${vo.answerContent}</span>、<span>答案</span>
                                    <textarea id="dx${vo.serial}" lay-verify="content" class="dodx"
                                              name="exDxList[${vo.serial}].answerAnalysis">${vo.answerAnalysis}</textarea><input
                                            type="hidden" class='dxyc' name="exDxList[${vo.serial}].answerContent"
                                            value="${vo.answerContent}">
                                </ul>
                            </#if>
                            <input type="hidden" name="exDxList[${vo.serial}].quAnswerId" value="${vo.quAnswerId}">
                        </#list>
                    </div>
                    <#if "${eq.status}"=="001">
                        <div class="col-md-2 layui-col-md-offset5  layui-btn-normal bluebg cursor"
                             style="margin-top: 10px;margin-left: calc(50% - 120px);display: inline-block; width: 200px; padding: 0 20px; height: 50px; line-height: 50px;border-radius: 3px"
                             onclick="addDx()">
                            <img src="${re.contextPath}/plugin/common/images/add-white.png"
                                 alt="" class="cursor"
                                 style="width:30px; margin: 10px;">
                            <span class="white">添加一个新的选项</span>
                        </div>
                    </#if>
                </div>
                <#--            多选题-->
                <div id="duox">
                    <div class="bold"><span class="red">*</span>选项(从选项中选择一个作为答案)</div>
                    <div id="duoxs">
                        <#list exq as vo>
                            <#if "${vo.isRight}"=="1">
                                <ul class="clearfix fl duox" style="width: 100%;">
                                    <input type="checkbox"
                                                                                               name="exDuoxList[${vo.serial}].isItRight"
                                                                                               style="display: none;"
                                                                                               checked="checked"
                                                                                               class="fl h30 w25 doBestInput"
                                                                                               value="${vo.answerContent}"><span>${vo.answerContent}</span>、<span>答案</span>
                                    <textarea id="duox${vo.serial}" class="doduox" lay-verify="content"
                                              name="exDuoxList[${vo.serial}].answerAnalysis">${vo.answerAnalysis}</textarea><input
                                            type="hidden" class='duoxyc' name="exDuoxList[${vo.serial}].answerContent"
                                            value="${vo.answerContent}">
                                </ul>
                            <#else >
                                <ul class="clearfix fl duox" style="width: 100%;">
                                    <input type="checkbox"
                                                                                               name="exDuoxList[${vo.serial}].isItRight"
                                                                                               style="display: none;"
                                                                                               class="fl h30 w25 doBestInput"
                                                                                               value="${vo.answerContent}"><span>${vo.answerContent}</span>、<span>答案</span>
                                    <textarea id="duox${vo.serial}" class="doduox" lay-verify="content"
                                              name="exDuoxList[${vo.serial}].answerAnalysis">${vo.answerAnalysis}</textarea><input
                                            type="hidden" class='duoxyc' name="exDuoxList[${vo.serial}].answerContent"
                                            value="${vo.answerContent}">
                                </ul>
                            </#if>
                            <input type="hidden" name="exDuoxList[${vo.serial}].quAnswerId" value="${vo.quAnswerId}">
                        </#list>
                    </div>
                    <#if "${eq.status}"=="001">
                        <div class="col-md-2 layui-col-md-offset5  layui-btn-normal bluebg cursor"
                             style="display: inline-block; width: 200px; padding: 0 20px; height: 50px; line-height: 50px;border-radius: 3px;margin-top: 10px;margin-left: calc(50% - 120px);"
                             onclick="addDuox()">
                            <img src="${re.contextPath}/plugin/common/images/add-white.png"
                                 alt="" class="cursor"
                                 style="width:30px; margin: 10px;">
                            <span class="white">添加一个新的选项</span>
                        </div>
                    </#if>
                </div>
                <#--			判断题-->
                <div id="pd">
                    <#list exq as vo>
                        <input type="hidden" name="exPdList[${vo.serial}].quAnswerId" value="${vo.quAnswerId}">
                    </#list>
                    <div class="bold"><span class="red">*</span>选项(从选项中选择一个作为答案)</div>
                    <ul class="clearfix fl" style="width: 100%;">
                        <#list exq as vo>
                            <#if  "${vo.isRight}"=="1" >
                                <input type="radio" name="exPdList[0].isItRight" value="${vo.answerContent}"
                                       title="${vo.answerContent}" checked="checked">
                            <#else>
                                <input type="radio" name="exPdList[0].isItRight" value="${vo.answerContent}"
                                       title="${vo.answerContent}">
                            </#if>
                            <input type="hidden" name="exPdList[0].quAnswerId" value="${vo.quAnswerId}">
                        </#list>
                        <input type="text" name="exPdList[0].answerContent" value="√" style="display:none">
                        <input type="text" name="exPdList[1].answerContent" value="×" style="display:none">
                    </ul>
                </div>
                <#--			填空题-->
                <div id="tk">
                    <div class="bold"><span class="red">*</span>答案</div>
                    <#list exq as vo>
                        <ul class="clearfix fl tk" style="width: 100%;">
                            <label class="fl w90" style="float: left">${vo.answerAnalysis}</label><input type="text"
                                                                                                         class="tiankong"
                                                                                                         name="exTkList[${vo.serial}].answerContent"
                                                                                                         value="${vo.answerContent}"
                                                                                                         placeholder="请输入内容">
                            <input type="hidden" class='tihao' name="exTkList[${vo.serial}].quAnswerId"
                                   value="${vo.quAnswerId}">
                            <img style="background-color: #3e7ce7"
                                 src="${re.contextPath}/plugin/common/images/30@2x.png" onclick="del(this)" alt=""
                                 class="">
                        </ul>
                    </#list>
                    <#--					<ul class="clearfix fl tk"  style="width: 100%;">-->
                    <#--						<label class="fl w90" style="float: left" >填空1</label><input type="text" name="exTkList[0].answerContent" placeholder="请输入内容">-->
                    <#--					</ul>-->
                    <div id="tks">
                    </div>
                    <#if "${eq.status}"=="001">
                        <div class="col-md-2 layui-col-md-offset5  layui-btn-normal bluebg cursor"
                             style="display: inline-block; width: 200px; padding: 0 20px; height: 50px; line-height: 50px;border-radius: 3px;margin-top: 10px;margin-left: calc(50% - 120px);"
                             onclick="addTk()">
                            <img src="${re.contextPath}/plugin/common/images/add-white.png"
                                 alt="" class="cursor"
                                 style="width:30px; margin: 10px;">
                            <span class="white">添加一个新的填空</span>
                        </div>
                    </#if>
                </div>
                <#--			问答题-->
                <div id="wd">
                    <#list exq as vo>
                        <input type="hidden" name="exWdList[0].quAnswerId" value="${vo.quAnswerId}">
                    </#list>
                    <div class="bold"><span class="red">*</span>问题答案</div>
                    <ul class="clearfix fl" style="width: 100%;">
                        <textarea id="wdt" lay-verify="content"
                                  name="exWdList[0].answerContent">${exq[0].answerContent}</textarea>

                    </ul>
                </div>
                <div class="bold">解析</div>
                <ul class="clearfix" style="width: 100%;">
                    <textarea id="analysis" lay-verify="content" name="analysis"
                              style="display: none;">${eq.analysis}</textarea>
                </ul>
                <div class="releaseBtn center" style="margin-top: 10px;">
                    <button type="button" class="white layui-btn layui-btn-normal  ft18 close">返回</button>
                    <#if "${eq.status}"=="001">
                        <button type="submit" lay-submit lay-filter="save"
                                class="layui-btn layui-btn-normal bluebg white ft18" id="btnsave">保存
                        </button>
                    </#if>
                    <button type="submit" lay-submit lay-filter="submit"
                            class="layui-btn layui-btn-normal bluebg white ft18" id="btnsubmit">提交
                    </button>
                    <#--				<button type="submit" lay-submit lay-filter="saves" class="layui-btn layui-btn-normal bluebg white ft18 " id="btnsave">保存并添加</button>-->
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/javascript">
    var layer;
    var form;
    var table = null;
    var tableIns = null;
    var layedit;
    var letter = new Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
    //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
    var element = "";
    layui.use(['element', 'laydate', 'layedit', 'form','tree'], function () {
        element = layui.element;
        form = layui.form;
        tree = layui.tree;
        layedit = layui.layedit;
        var content = layedit.build('content',{
            tool: [ 'strong','italic','underline','del', '|','left', 'center', 'right']
        }); //建立编辑器
        var analysis = layedit.build('analysis',{
            tool: [ 'strong','italic','underline','del', '|','left', 'center', 'right']
        }); //建立编辑器
        var wdt = layedit.build('wdt');
        window.check = function (bjq) {
            layedit.build(bjq,{
                tool: [ 'strong','italic','underline','del', '|','left', 'center', 'right']
            });
        };

        /*试卷分类*/
        var paperSort = "${eq.quCategory}"

        /*处理试题分类-树显示*/
        var treeDto = [];
        /*执行查询分类*/
        $(function (){
            layerAjaxGet('/ex/question/selectTypeClassifyQu', {}, '', function (res) {
                if (200 == res.code){
                    treeDto = res.data;
                    tree.render({
                        elem: "#classtree",
                        data: treeDto,
                        click: function (node) {
                            /*当前选择的回显*/
                            $('#treeclass').html(node.data.title);
                            /*回显隐藏id*/
                            $('#quCategory').val(node.data.id)
                            var $select = $($(this)[0].elem).parents(".layui-form-select");
                            $select.removeClass("layui-form-selected").find(".layui-select-title span").html(node.name).end().find("input:hidden[name='selectID']").val(node.id);
                        }
                    });
                    treeChecked();
                }
            })
        })

        /*编辑时，回显树形数据指定数据*/
        function treeChecked(){
            for (var i = 0; i < treeDto.length; i++){
                var oneId = treeDto[i]; // 第一级目录
                if (oneId.id == paperSort){
                    $('#treeclass').html(oneId.title);
                    $('#quCategory').val(oneId.id)
                    return;
                }
                if (oneId.children.length != 0){
                    for (var j = 0; j < oneId.children.length; j ++){
                        var twoId = oneId.children[j];
                        if (twoId.id == paperSort){
                            $('#treeclass').html(twoId.title);
                            $('#quCategory').val(twoId.id)
                            return;
                        }
                    }
                }
            }
        }

        /*点击输入框*/
        $(".downpanel").on("click", ".layui-select-title", function (e) {
            $(".layui-form-select").not($(this).parents(".layui-form-select")).removeClass("layui-form-selected");
            $(this).parents(".downpanel").toggleClass("layui-form-selected");
            layui.stope(e);
        }).on("click", "dl i", function (e) {
            // 点击展开菜单
            layui.stope(e);
        });
        /*这个是点击的那个*/
        $(document).on("click", function (e) {
            $(".layui-form-select").removeClass("layui-form-selected");
        });

        form.verify({
            //content富文本域中的lay-verify值
            content: function (value) {
                layedit.sync(wdt);
                //单选和多选的富文本
                var index = $("textarea").length;
                $(".layui-layedit-iframe").find("iframe").each(function (i,v){
                    var  id=$(v).attr("id");
                    var  idnum= id.replaceAll("LAY_layedit_","");
                    layedit.sync(idnum);
                });
            }
        });
        //保存
        form.on('submit(save)', function (data) {
            var datas = data.field;
            // datas.content = layedit.getContent(content);
            // datas.analysis = layedit.getContent(analysis);
            if (!datas.content) {
                layer.msg("题目名称不能为空", {icon: 2});
                return false;
            }
            datas.status = '001';
            layerAjax("/ex/question/insertSt", datas, '', function (d) {
                if (d.flag) {
                    layer.msg("保存成功！", {icon: 1});
                    $('#btnsubmit').addClass("layui-btn-disabled").attr("disabled", true);
                    $('#btnsave').addClass("layui-btn-disabled").attr("disabled", true);
                    setTimeout(function () {
                        window.parent._showtab('5253b2f369364ceca7dbca94a85b68ca', '试题库', '/ex/question/stkIndex');
                    }, 1000)
                } else {
                    // $('#btnsubmit').addClass("layui-btn-disabled").attr("disabled", false);
                    // $('#btnsave').addClass("layui-btn-disabled").attr("disabled", false);
                    layer.msg(d.msg, {icon: 2});
                    return false;
                }
            })
            return false;
        });
        //提交
        form.on('submit(submit)', function (data) {
            var datas = data.field;
            datas.content = layedit.getContent(content);
            datas.analysis = layedit.getContent(analysis);
            if (!datas.content) {
                layer.msg("题目名称不能为空", {icon: 2});
                return false;
            }
            datas.status = '002';
            layerAjax("/ex/question/insertSt", datas, '', function (d) {
                if (d.flag) {
                    layer.msg("提交成功！", {icon: 1});
                    $('#btnsubmit').addClass("layui-btn-disabled").attr("disabled", true);
                    $('#btnsave').addClass("layui-btn-disabled").attr("disabled", true);
                    setTimeout(function () {
                        window.parent._showtab('5253b2f369364ceca7dbca94a85b68ca', '试题库', '/ex/question/stkIndex');
                    }, 1000)
                } else {
                    // $('#btnsubmit').addClass("layui-btn-disabled").attr("disabled", false);
                    // $('#btnsave').addClass("layui-btn-disabled").attr("disabled", false);
                    layer.msg(d.msg, {icon: 2});
                    return false;
                }
            })
            return false;
        });
        //保存并添加
        form.on('submit(saves)', function (data) {
            var datas = data.field;
            datas.content = layedit.getContent(content);
            datas.analysis = layedit.getContent(analysis);
            if (!datas.content) {
                layer.msg("题目名称不能为空", {icon: 2});
                return false;
            }
            datas.status = '001';
            layerAjax("/ex/question/insertSt", datas, '', function (d) {
                if (d.flag) {
                    layer.msg("保存成功！", {icon: 1});
                    setTimeout(function () {
                        window.location.reload();
                    }, 1000)
                } else {
                    layer.msg("保存失败！", {icon: 2});
                    return false;
                }
            })
            return false;
        });
    });
    //取消按钮
    $('.close').click(function () {
        window.parent._showtab('', '试题库', '/ex/question/stkIndex');
    });
    $(function () {
        var code = ${eq.quType};
        lxChange(code);
    })

    //选择试题类型进行切换数据
    function lxChange(code) {
        if (code == '001') {
            $("#dx").show();
            $("#wd").hide();
            $("#pd").hide();
            $("#tk").hide();
            $("#duox").hide();
            let index = ${index};
            let a = 0
            //为每个选项生成富文本
            for (let i = 0; i < index; i++) {
                layui.use(['layedit'], function () {
                    let layedit = layui.layedit;
                    layedit.build('dx' + a,{
                        tool: [ 'strong','italic','underline','del', '|','left', 'center', 'right']
                    });
                    a++;
                })
            }
        }
        if (code == '002') {
            $("#duox").show();
            $("#wd").hide();
            $("#dx").hide();
            $("#tk").hide();
            $("#pd").hide();
            let index = ${index};
            let a = 0
            //为每个选项生成富文本
            for (let i = 0; i < index; i++) {
                layui.use(['layedit'], function () {
                    let layedit = layui.layedit;
                    layedit.build('duox' + a,{
                        tool: [ 'strong','italic','underline','del', '|','left', 'center', 'right']
                    });
                    a++;
                })
            }

        }
        if (code == '003') {
            $("#pd").show();
            $("#wd").hide();
            $("#dx").hide();
            $("#tk").hide();
            $("#duox").hide();

        }
        if (code == '004') {
            $("#tk").show();
            $("#pd").hide();
            $("#wd").hide();
            $("#dx").hide();
            $("#duox").hide();

        }
        if (code == '005') {
            $("#wd").show();
            $("#dx").hide();
            $("#tk").hide();
            $("#pd").hide();
            $("#duox").hide();
        }

    }

    //增加单选题
    function addDx() {

        var index = $(".dx").length;
        var dx = $("<ul class=\"clearfix fl dx\"  style=\"width: 100%;position: relative\">\n<input type=\"radio\" name=\"exDxList[0].isItRight\" style=\"display: none;\"  class=\"fl h30 w25 doBestInput\" value=\"" + letter[index] + "\"><div class=\'layui-unselect layui-form-radio\'><i class=\'layui-anim layui-icon\'></i><div></div></div>" +
            "\t\t\t\t\t<span>" + letter[index] + "</span>、<span class=\"da\">答案</span>\n" +
            "\t\t\t\t\t<textarea id=\"dx" + index + "\" class=\"dodx\" lay-verify=\"content\" name=\"exDxList[" + index + "].answerAnalysis\"></textarea><input type=\"hidden\" class='dxyc' name=\"exDxList[" + index + "].answerContent\" value=\"" + letter[index] + "\">\n" +
            "\t\t\t\t</ul>");
        var b = $("<img src=\"${re.contextPath}/plugin/common/images/30@2x.png\"  style=\"position:absolute;top:35px;right:-25px;background:#3e7ce7\"  onclick=\"delDx(this)\" alt=\"\" class=\"\">");
        b.click(delDx);
        var bjq = "dx" + index
        //延迟让标签先生成
        setTimeout(function () {
            dx.append(b)
            check(bjq);
        }, 1);
        $("#dxs").append(dx);

        form.render();
    }

    function delDx(Object) {
        $(this).parent().remove();
        if ($(this).parent().length > 0) {
            var ssses = $(".dodx");
            if (ssses.length > 0) {
                formatDXInd();
            }
        }
        form.render();
    }

    //删除后剩余重新排序
    function formatDXInd() {
        var ssses = $(".dodx");
        $.each(ssses, function (ind, obj) {
            var oldAttrName = $(obj).attr('name');
            if (oldAttrName) {
                var front = oldAttrName.substring(0, oldAttrName.indexOf("[") + 1);
                var back = oldAttrName.substring(oldAttrName.indexOf("]"), oldAttrName.length);
                var newName = front + (ind) + back;
                $(obj).attr('name', newName);
                $(obj).attr('id', "dx" + ind);
                $(obj).prev().prev().prev().prev().attr('value', letter[(ind)]);
                $(obj).prev().prev().text(letter[(ind)]);
                layedit.build("dx" + ind, {
                    tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right']
                });
            }
        })
        //遍历隐藏框
        var ssse = $(".dxyc");
        $.each(ssse, function (ind, obj) {
            var oldAttrName = $(obj).attr('name');
            if (oldAttrName) {
                var front = oldAttrName.substring(0, oldAttrName.indexOf("[") + 1);
                var back = oldAttrName.substring(oldAttrName.indexOf("]"), oldAttrName.length);
                var newName = front + (ind) + back;
                $(obj).attr('name', newName);
                $(obj).attr('value', letter[ind]);

            }
        })
    }

    //增加多选题
    function addDuox() {
        var index = $(".duox").length;
        let duox = $("<ul class=\"clearfix fl duox\"  style=\"width: 100%;position: relative\">\n<input type=\"checkbox\" name=\"exDuoxList[" + index + "].isItRight\" style=\"display: none;\" class=\"fl h30 w25 doBestInput\" value=\"" + letter[index] + "\"><div class=\'layui-unselect layui-form-checkbox\'><i class=\'layui-anim layui-icon\'></i><div></div></div>" +
            "\t\t\t\t\t<span class=\"answerContent\">" + letter[index] + "</span>、<span class=\"da\">答案</span>\n" +
            "\t\t\t\t\t<textarea id=\"duox" + index + "\" class=\"doduox\" lay-verify=\"content\" style=\"display: none;\" name=\"exDuoxList[" + index + "].answerAnalysis\"></textarea><input type=\"hidden\" class='duoxyc' name=\"exDuoxList[" + index + "].answerContent\" value=\"" + letter[index] + "\">\n" +
            "\t\t\t\t</ul>");
        var b = $("<img src=\"${re.contextPath}/plugin/common/images/30@2x.png\"  style=\"position:absolute;top:35px;right:-25px;background:#3e7ce7\"  onclick=\"delDuox(this)\" alt=\"\" class=\"\">");
        b.click(delDuox);
        var bjq = "duox" + index
        //延迟让标签先生成
        setTimeout(function () {
            duox.append(b)
            check(bjq);
        }, 1);
        $("#duoxs").append(duox);

        form.render();
    }

    function delDuox(Object) {
        $(this).parent().remove();
        if ($(this).parent().length > 0) {
            var ssses = $(".doduox");
            if (ssses.length > 0) {
                formatDUOXInd();
            }
        }
        form.render();
    }

    //删除后剩余重新排序
    function formatDUOXInd() {
        var ssses = $(".doduox");
        $.each(ssses, function (ind, obj) {
            var oldAttrName = $(obj).attr('name');
            var oldAttrNames = $(obj).prev().prev().prev().prev().attr('name');
            if (oldAttrName) {
                var front = oldAttrName.substring(0, oldAttrName.indexOf("[") + 1);
                var back = oldAttrName.substring(oldAttrName.indexOf("]"), oldAttrName.length);
                var newName = front + (ind) + back;
                $(obj).attr('name', newName);
                $(obj).attr('id', "duox" + ind);
                $(obj).prev().prev().prev().prev().attr('value', letter[(ind)]);
                $(obj).prev().prev().text(letter[(ind)]);
                layedit.build("duox" + ind, {
                    tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right']
                });
            }
            if (oldAttrNames) {
                var front = oldAttrNames.substring(0, oldAttrNames.indexOf("[") + 1);
                var back = oldAttrNames.substring(oldAttrNames.indexOf("]"), oldAttrNames.length);
                var newName = front + (ind) + back;
                $(obj).prev().prev().prev().prev().attr('name', newName);
            }
        })
        //遍历隐藏框
        var ssse = $(".duoxyc");
        $.each(ssse, function (ind, obj) {
            var oldAttrName = $(obj).attr('name');
            if (oldAttrName) {
                var front = oldAttrName.substring(0, oldAttrName.indexOf("[") + 1);
                var back = oldAttrName.substring(oldAttrName.indexOf("]"), oldAttrName.length);
                var newName = front + (ind) + back;
                $(obj).attr('name', newName);
                $(obj).attr('value', letter[ind]);

            }
        })
    }

    //增加填空题
    function addTk() {
        var index = $(".tk").length;
        var i = $(".tk").length - 1;
        var tk = $("<ul class=\"clearfix fl tk\"  style=\"width: 100%;position:relative;\">\n" +
            "\t\t\t\t\t\t<label class=\"fl w90\" style=\"float: left\" >填空" + (index + 1) + "</label><input type=\"text\" class=\"tiankong\" name=\"exTkList[" + (i + 1) + "].answerContent\" placeholder=\"请输入内容\">" +
            "<input type=\"hidden\" class='tihao' name=\"exTkList[" + (i + 1) + "].answerAnalysis\" value=\"填空" + (index + 1) + "\"></ul>");

        var b = $("<img src=\"${re.contextPath}/plugin/common/images/30@2x.png\" style=\"position:absolute;top:4px;left:273px;background-color:#3e7ce7\" onclick=\"del(this)\" alt=\"\" class=\"\">");
        b.click(del);
        tk.append(b)
        $("#tks").append(tk);

        form.render();
    }

    function del(Object) {
        $(this).parent().remove();
        if ($(this).parent().length > 0) {
            var ssses = $(".tiankong");
            if (ssses.length > 0) {
                formatFBInd();
            }
        }
    }

    //删除后剩余重新排序
    function formatFBInd() {
        var ssses = $(".tiankong");
        $.each(ssses, function (ind, obj) {
            var oldAttrName = $(obj).attr('name');
            if (oldAttrName) {
                var front = oldAttrName.substring(0, oldAttrName.indexOf("[") + 1);
                var back = oldAttrName.substring(oldAttrName.indexOf("]"), oldAttrName.length);
                var newName = front + (ind) + back;
                $(obj).attr('name', newName);
                //更改 分包编号x
                $(obj).prev().html("填空" + (ind * 1 + 1));
            }
        })
        //遍历隐藏框
        var ssse = $(".tihao");
        $.each(ssse, function (ind, obj) {
            var oldAttrName = $(obj).attr('name');
            if (oldAttrName) {
                var front = oldAttrName.substring(0, oldAttrName.indexOf("[") + 1);
                var back = oldAttrName.substring(oldAttrName.indexOf("]"), oldAttrName.length);
                var newName = front + (ind) + back;
                $(obj).attr('name', newName);
                $(obj).attr('value', "填空" + (ind * 1 + 1));

            }
        })
    }


</script>
</body>

</html>
